package com.sskj.givecoin.p.activity;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.givecoin.m.HttpConfig;
import com.sskj.givecoin.m.bean.HttpData;
import com.sskj.givecoin.m.bean.TransferHistory;
import com.sskj.givecoin.m.http.JsonCallBack;
import com.sskj.givecoin.p.base.BasePresenter;
import com.sskj.givecoin.v.activity.TransferHistoryActivity;

import java.util.List;

/**
 * @author Hey
 * @des
 * @date 2018/8/7 11:20
 */
public class TransferHistoryPresenter extends BasePresenter<TransferHistoryActivity> {
    public void getTransferHistory(int page) {
        OkGo.<HttpData<List<TransferHistory>>>get(HttpConfig.BASE_URL + HttpConfig.TRANSFER_HISTORY)
                .params("p", page)
                .execute(new JsonCallBack<HttpData<List<TransferHistory>>>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData<List<TransferHistory>>> response) {
                        if (response.body().status == 200) {
                            mView.setHistoryList(response.body().getData());
                        }
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }
}
